package com.titan.core.utils.io;

import org.apache.commons.lang3.StringUtils;

import com.titan.core.utils.data.FormatUtils;

/**
 * @author 周成功
 * @email 86898837@qq.com
 * @date 2020年02月10日
 */
public class ConsoleUtils {
    public static void out(Object...args) {
    	StringBuilder buffer = new StringBuilder(256);
        buffer.append("[").append(FormatUtils.getSysdate("HH:mm:ss.SSS")).append("]");
        if( (args==null)||(args.length==0) ) {
            System.out.println(buffer.toString());
            return;
        }
        for (Object object : args) {
            buffer.append(FormatUtils.toString(object));
        }
        System.out.println(buffer.toString());
    }


    public static void log(Object k1) {
        out(" [", k1, "]");
    }
    public static void log(Object k1, Object v1) {
        out(" [", k1, "=", v1, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2, Object k3, Object v3) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9, Object k10, Object v10) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]", " [", k10, "=", v10, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9, Object k10, Object v10, Object k11, Object v11) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]", " [", k10, "=", v10, "]", " [", k11, "=", v11, "]");
    }
    public static void log(Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9, Object k10, Object v10, Object k11, Object v11, Object k12, Object v12) {
        out(" [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]", " [", k10, "=", v10, "]", " [", k11, "=", v11, "]", " [", k12, "=", v12, "]");
    }    
    
    public static void log(String prefix, Object k1, Object v1) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9, Object k10, Object v10) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]", " [", k10, "=", v10, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9, Object k10, Object v10, Object k11, Object v11) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]", " [", k10, "=", v10, "]", " [", k11, "=", v11, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9, Object k10, Object v10, Object k11, Object v11, Object k12, Object v12) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]", " [", k10, "=", v10, "]", " [", k11, "=", v11, "]", " [", k12, "=", v12, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9, Object k10, Object v10, Object k11, Object v11, Object k12, Object v12, Object k13, Object v13) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]", " [", k10, "=", v10, "]", " [", k11, "=", v11, "]", " [", k12, "=", v12, "]", " [", k13, "=", v13, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9, Object k10, Object v10, Object k11, Object v11, Object k12, Object v12, Object k13, Object v13, Object k14, Object v14) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]", " [", k10, "=", v10, "]", " [", k11, "=", v11, "]", " [", k12, "=", v12, "]", " [", k13, "=", v13, "]", " [", k14, "=", v14, "]");
    }
    public static void log(String prefix, Object k1, Object v1, Object k2, Object v2, Object k3, Object v3, Object k4, Object v4, Object k5, Object v5, Object k6, Object v6, Object k7, Object v7, Object k8, Object v8, Object k9, Object v9, Object k10, Object v10, Object k11, Object v11, Object k12, Object v12, Object k13, Object v13, Object k14, Object v14, Object k15, Object v15) {
        out(" [", prefix, "] ", " [", k1, "=", v1, "]", " [", k2, "=", v2, "]", " [", k3, "=", v3, "]", " [", k4, "=", v4, "]", " [", k5, "=", v5, "]", " [", k6, "=", v6, "]", " [", k7, "=", v7, "]", " [", k8, "=", v8, "]", " [", k9, "=", v9, "]", " [", k10, "=", v10, "]", " [", k11, "=", v11, "]", " [", k12, "=", v12, "]", " [", k13, "=", v13, "]", " [", k14, "=", v14, "]", " [", k15, "=", v15, "]");
    }
    
    
    public static void method(Class clazz, String methodName) {
    	method(clazz, methodName, null, null);
    }
    public static void method(Class clazz, String methodName, String name1, Object value1) {
    	method(clazz, methodName, name1, value1, null, null);
    }
    public static void method(Class clazz, String methodName, String name1, Object value1, String name2, Object value2) {
    	method(clazz, methodName, name1, value1, name2, value2, null, null);
    }
    public static void method(Class clazz, String methodName, String name1, Object value1, String name2, Object value2, String name3, Object value3) {
        method(clazz, methodName, name1, value1, name2, value2, name3, value3, null, null);
    }
    public static void method(Class clazz, String methodName, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) {
        method(clazz, methodName, name1, value1, name2, value2, name3, value3, name4, value4, null, null);
    }
    public static void method(Class clazz, String methodName, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5) {
        method(clazz, methodName, name1, value1, name2, value2, name3, value3, name4, value4, name5, value5, null, null);
    }
    public static void method(Class clazz, String methodName, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6) {
        method(clazz, methodName, name1, value1, name2, value2, name3, value3, name4, value4, name5, value5, name6, value6, null, null);
    }
    public static void method(Class clazz, String methodName, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7) {
        method(clazz, methodName, name1, value1, name2, value2, name3, value3, name4, value4, name5, value5, name6, value6, name7, value7, null, null);
    }
    public static void method(Class clazz, String methodName, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8) {
        method(clazz, methodName, name1, value1, name2, value2, name3, value3, name4, value4, name5, value5, name6, value6, name7, value7, name8, value8, null, null);
    }
    public static void method(Class clazz, String methodName, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4, String name5, Object value5, String name6, Object value6, String name7, Object value7, String name8, Object value8, String name9, Object value9) {
        StringBuilder buf = new StringBuilder(128);
        if(clazz!=null) {
            buf.append("执行类[").append(clazz.getName()).append("]");
        }
        if(StringUtils.isNotEmpty(methodName)) {
        	buf.append("的方法[").append(methodName).append("]");
        }
        if(StringUtils.isNotEmpty(name1)) {
        	buf.append(" [").append(name1).append("=").append(FormatUtils.toString(value1)).append("]");
        }
        if(StringUtils.isNotEmpty(name2)) {
        	buf.append(" [").append(name2).append("=").append(FormatUtils.toString(value2)).append("]");
        }
        if(StringUtils.isNotEmpty(name3)) {
        	buf.append(" [").append(name3).append("=").append(FormatUtils.toString(value3)).append("]");
        }
        if(StringUtils.isNotEmpty(name4)) {
            buf.append(" [").append(name4).append("=").append(FormatUtils.toString(value4)).append("]");
        }
        if(StringUtils.isNotEmpty(name5)) {
            buf.append(" [").append(name5).append("=").append(FormatUtils.toString(value5)).append("]");
        }
        if(StringUtils.isNotEmpty(name6)) {
            buf.append(" [").append(name6).append("=").append(FormatUtils.toString(value6)).append("]");
        }
        if(StringUtils.isNotEmpty(name7)) {
            buf.append(" [").append(name7).append("=").append(FormatUtils.toString(value7)).append("]");
        }
        if(StringUtils.isNotEmpty(name8)) {
            buf.append(" [").append(name8).append("=").append(FormatUtils.toString(value8)).append("]");
        }
        if(StringUtils.isNotEmpty(name9)) {
            buf.append(" [").append(name9).append("=").append(FormatUtils.toString(value9)).append("]");
        }
        out(buf.toString());
    }

    
    public static void printPart(String title, Object...conntext) {
        System.out.println("\n");
        System.out.println("==  " + title + "  ==============================================");
        if(conntext!=null && conntext.length>0) {
            for (int i = 0; i < conntext.length; i++) {
                System.out.println(FormatUtils.toString(conntext[i]));
            }
        }
    }    
    
}




